package org.wheel.plugins.toolkit.sql.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * 比较运算符枚举
 *
 * 统一 WHERE、ON、HAVING 里所有二元比较的原子类型
 */
@Getter
@RequiredArgsConstructor
public enum CompareType {

    /* ---------- 常规 ---------- */
    EQ("=", "eq"),
    NE("<>", "ne"),
    GT(">", "gt"),
    GE(">=", "ge"),
    GTE(">=", "gte"),
    LT("<", "lt"),
    LE("<=", "lte"),
    LTE("<=", "lte"),

    /* ---------- 模糊 ---------- */
    LIKE("LIKE", "like"),
    LEFT_LIKE("LIKE", "leftLike"),
    RIGHT_LIKE("LIKE", "rightLike"),
    NOT_LIKE("NOT LIKE", "notLike"),

    /* ---------- 空值 ---------- */
    IS_NULL("IS NULL", "isNull"),
    IS_NOT_NULL("IS NOT NULL", "isNotNull"),

    /* ---------- 集合 ---------- */
    IN("IN", "in"),
    NOT_IN("NOT IN", "notIn"),
    BETWEEN("BETWEEN", "between"),
    NOT_BETWEEN("NOT BETWEEN", "notBetween");

    /** 数据库运算符 */
    private final String op;
    private final String placeholder;

    /**
     * 是否需要右值（:param）
     * 例如 IS_NULL 不需要，EQ、LIKE、BETWEEN 需要
     */
    public boolean requireValue() {
        return this == IS_NULL || this == IS_NOT_NULL;
    }
}